package com.saihai.jiankang.ufQjxgwh.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.enums.BusinessType;
import com.saihai.jiankang.ufQjxgwh.domain.UfQjxgwh;
import com.saihai.jiankang.ufQjxgwh.service.IUfQjxgwhService;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.common.core.page.TableDataInfo;

/**
 * 后台字典Controller
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/jiankang/ufQjxgwh")
public class UfQjxgwhController extends BaseController
{
    @Autowired
    private IUfQjxgwhService ufQjxgwhService;

    /**
     * 查询后台字典列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UfQjxgwh ufQjxgwh)
    {
        List<UfQjxgwh> list = ufQjxgwhService.selectUfQjxgwhList(ufQjxgwh);
        return getDataTable(list);
    }

    /**
     * 查询后台字典列表
     */
    @GetMapping("/getDictData")
    public TableDataInfo getDictData(UfQjxgwh ufQjxgwh)
    {
        List<UfQjxgwh> list = ufQjxgwhService.selectUfQjxgwhList(ufQjxgwh);
        return getDataTable(list);
    }

    /**
     * 导出后台字典列表
     */
    @Log(title = "后台字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfQjxgwh ufQjxgwh)
    {
        List<UfQjxgwh> list = ufQjxgwhService.selectUfQjxgwhList(ufQjxgwh);
        ExcelUtil<UfQjxgwh> util = new ExcelUtil<UfQjxgwh>(UfQjxgwh.class);
        util.exportExcel(response, list, "后台字典数据");
    }

    /**
     * 获取后台字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufQjxgwh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufQjxgwhService.selectUfQjxgwhById(id));
    }

    /**
     * 新增后台字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufQjxgwh:add')")
    @Log(title = "后台字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfQjxgwh ufQjxgwh)
    {
        return toAjax(ufQjxgwhService.insertUfQjxgwh(ufQjxgwh));
    }

    /**
     * 修改后台字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufQjxgwh:edit')")
    @Log(title = "后台字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfQjxgwh ufQjxgwh)
    {
        return toAjax(ufQjxgwhService.updateUfQjxgwh(ufQjxgwh));
    }

    /**
     * 删除后台字典
     */
    @PreAuthorize("@ss.hasPermi('jiankang:ufQjxgwh:remove')")
    @Log(title = "后台字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufQjxgwhService.deleteUfQjxgwhByIds(ids));
    }
}
